/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package superchat;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JList;
import javax.swing.ListModel;

/**
 * Classe pour l'évenement double clic sur la liste des utilisateurs connectés
 */
class ActionJList extends MouseAdapter {

    protected SuperChatView parent;
    protected JList list;

    public ActionJList(JList l, SuperChatView p) {
        list = l;
        parent = p;
    }

    public void mouseClicked(MouseEvent e) {
        if (e.getClickCount() == 2) {
            int index = list.locationToIndex(e.getPoint());
            if (index >= 0) {
                ListModel dlm = list.getModel();
                Object item = dlm.getElementAt(index);
                list.ensureIndexIsVisible(index);
                parent.add_chan(item.toString());
            }
        }
    }
}